﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class RetraitForm : Form
    {
        private Bordereau bordereau = new Bordereau();

        public RecherchebordereauForm   recherchebordereau { get; set; }
        
        public RetraitForm()
        {
            InitializeComponent();
            RAMEDEntities1 context = SingletonContext.GetContext();
            comboBoxfonctionnaire.DataSource = context.Responsables;
            comboBoxfonctionnaire.DisplayMember = "nom_prenom_responsable";

        }

        public void remplirChamps()
        {

            Annexelabel.Text = Bord.Annexe_administratif.nom_annexe_administratif;
            NumBordereaulabel.Text = Bord.Lot.num_de_lot.Value.ToString();
           
           
        }

        private void btnenregistrer_Click(object sender, EventArgs e)
        {


            RAMEDEntities1 context = SingletonContext.GetContext();
            Bordereau borer = new Bordereau();
            borer = context.Bordereaux.Where(b => b.id_bordereau == Bord.id_bordereau).First();
            borer.Retrait = true;
            Responsable responsable = (Responsable) comboBoxfonctionnaire.SelectedValue;
            borer.id_responsable = responsable.id_responsable;
            borer.date_bordereau = dateTimePickerdate.Value;
            recherchebordereau.mettreAjouterFormGridViewbor();
            context.SaveChanges();
            this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        public Bordereau Bord { get; set; }

        internal void InitialiserChamps()
        {
            remplirChamps();
        }

        private void Button21_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void RetraitForm_Load(object sender, EventArgs e)
        {

        }
    }
}
